package com.manli.timing.controller;

import com.manli.timing.service.TimingService;
import com.manli.timing.utils.DateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 定时任务
 *
 * @author manli
 * @email 
 * @date 2020-05-15 11:39:04
 */
@Api(value="/", tags="定时任务")
@RestController
@RequestMapping("api/timing")
public class TimingController {
    @Autowired
    private TimingService timingService;

//    /**
//     * 定时获取已经结算的淘宝客单子,每15分钟获取一次，因为双十一，618等大促的查询时间必须小于20分钟
//     */
//    @Scheduled(cron = "0 0/15 * * * *")
//    @ApiOperation(value = "定时获取已经结算的淘宝客单子",notes = "")
//    @GetMapping("/getTaoBaoKeOrders")
//    public void getTaoBaoKeOrders()throws Exception{
//        String startTime = DateUtils.get15minsAgo();
//        String endTime = DateUtils.getNow();
////        String startTime = "2020-06-30 10:00:00";
////        String endTime = "2020-06-30 12:00:00";
//        timingService.getTaoBaoKeOrders("1",startTime,endTime);
//    }
//
//    /**
//     * 定时查询已经获取的淘宝客单子的状态变化
//     */
//    @Scheduled(cron = "0 0/60 * * * *")
//    @ApiOperation(value = "定时查询已经获取的淘宝客单子的状态变化",notes = "")
//    @GetMapping("/getTaoBaoKeOrdersStatus")
//    public void getTaoBaoKeOrdersStatus()throws Exception{
//        timingService.getTaoBaoKeOrdersStatus();
//    }

    /**
     * 定时更新支付状态,超过七天自动变成完成状态 一小时执行
     */
    @Scheduled(cron = "0 0/60 * * * *")
    @ApiOperation(value = "定时更新支付状态,超过七天自动变成完成状态",notes = "")
    @GetMapping("/changeOrderInfoStatus")
    public void changeOrderInfoStatus()throws Exception{
        timingService.changeOrderInfoStatus();
    }

    /**
     * 定时查询已经支付的一元拍卖的预支付订单 一小时执行
     */
    @Scheduled(cron = "0 0/60 * * * *")
    @ApiOperation(value = "退款一元拍卖的不是最高价的记录",notes = "")
    @GetMapping("/refuseOneYuanNotMostPrice")
    public void refuseOneYuanNotMostPrice()throws Exception{
        timingService.refuseOneYuanNotMostPrice();
    }

    /**
     * 定时查询已经支付的一元拍卖的预支付订单 一小时执行
     */
    @Scheduled(cron = "0 0/60 * * * *")
    @ApiOperation(value = "拼团没成功退款",notes = "")
    @GetMapping("/refusePingTuanNoSuccess")
    public void refusePingTuanNoSuccess()throws Exception{
        timingService.refusePingTuanNoSuccess();
    }

    /**
     * 定时统计商品评价表信息，每天24点执行
     */
    @Scheduled(cron = "0 0 0 * * *")
    @ApiOperation(value = "定时统计商品评价表信息",notes = "")
    @GetMapping("/statisticsAppraiseInfo")
    public void statisticsAppraiseInfo()throws Exception{
        timingService.statisticsAppraiseInfo();
    }

    /**
     * 定时查询激活商家微信代金券
     */
    @Scheduled(cron = "0 0/3 * * * *")
    @ApiOperation(value = "激活商家微信代金券",notes = "")
    @GetMapping("/activeBranchWeChatCoupons")
    public void activeBranchWeChatCoupons()throws Exception{
        timingService.activeBranchWeChatCoupons();
    }


}
